﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Input;
using DocumentsTagger.UI.ViewModel;

namespace DocumentsTagger.UI.Commands
{
    public class AddWatchedDirectoryCommand: ACommandBase
    {
        private readonly ScannerOptionsViewModel r_vm;
        public AddWatchedDirectoryCommand(ScannerOptionsViewModel vm)
        {
            r_vm = vm;
        }

        /// <summary>
        /// returns the ability to execute the command
        /// </summary>
        /// <param name="parameter">can be null</param>
        /// <returns>true if the command can be executed</returns>
        public override bool CanExecute(object parameter)
        {
            return !string.IsNullOrEmpty(r_vm.SelectedFileSystemDirectory); 
        }

        /// <summary>
        /// Executes the command.
        /// </summary>
        /// <param name="parameter">Can be null</param>
        public override void Execute(object parameter)
        {
            r_vm.AddToWatchedDirectories();
        }
    }
}
